import 'dart:async';
import 'package:chop/Model/user_rider_entity.dart';
import 'package:chop/view/Driver/newsOrder.dart';
import 'package:chop/widgets/TextSizeWidget.dart';
import 'package:chop/widgets/appBar.dart';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:get/get.dart';

import 'DriverPersonal_center.dart';

class Driverhome extends StatefulWidget {
  @override
  _DriverhomeState createState() => _DriverhomeState();
}

class _DriverhomeState extends State<Driverhome> {
  Position position;
  bool isNetWorkBad = false; //network
  int text = 0;
  List<Widget> pageViews = [];
  UserRider rider;
  Timer timerr;
  TabController tabController;

  @override
  void initState() {
    pageViews = [
      NewsOrder(),
      NewsOrder(),
    ];
    tabController = TabController(length: 2, vsync: ScaffoldState());
    // TODO: implement initState
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: BaseViewBar(
        childView: BaseTitleBar(
          "ChopChop",
          leftIcon: Icons.account_box,
          leftClick: () {
            Get.to(DriverPersonal_center());
          },
        ),
        preferredSize: Size.fromHeight(50.00),
      ),
      body: getBody(),
    );
  }



  Widget getBody() {
    return _buildBody();
//    if (isNetWorkBad) {
//
//    } else {
//      return Center(
//        child: CircularProgressIndicator(),
//      );
//    }
  }

  void showSnack() {
    Get.snackbar("23", "1231");
  }

  Widget _buildBody() {
    return Scaffold(
        appBar: PreferredSize(
          preferredSize: Size.fromHeight(40.00),
          child: Material(
            color: Colors.blueAccent,
            child: TabBar(
              controller: tabController,
              tabs: <Widget>[
                Tab(
                  child: FixedSizeText("实时订单"),
                ),
                Tab(
                  child: FixedSizeText("历史订单"),
                ),
              ],
            ),
          ),
        ),
        body: TabBarView(
          controller: tabController,
          children: pageViews,
        ));
  }
}

class MyNotification extends Notification {
  MyNotification(this.msg);

  final String msg;
}
